import { Component, OnInit,Input,EventEmitter,Output } from '@angular/core';
import {Service} from '../../server/server';
import {HttpClient} from '@angular/common/http';

declare var $:any;

@Component({
    selector: 'app-internal-modal-autocomplate',
    templateUrl: './internal-modal-autocomplate.component.html',
    styleUrls: ['./internal-modal-autocomplate.component.css']
})
export class InternalModalAutocomplateComponent implements OnInit {

    @Input() internalParam : any;
    public internalRightClickMenuEmit: any;
    currentSelectedTxt :string = '';

    constructor( private server: Service,private http: HttpClient) { }

    ngOnInit() {
        //internalThemeWordsLeftEmit
        this.internalRightClickMenuEmit = this.server.internalRightClickMenuEmit.subscribe((value: any) => {
            if (value) {
                this.currentSelectedTxt = value;
                $('#mat-input-1').val('');
            }
        });
    }

    ngOnDestroy() {
        this.internalRightClickMenuEmit ? this.internalRightClickMenuEmit.unsubscribe() : '';
    }


    findThemeContent(val) {
        //回车接收值
        if (Object.prototype.toString.call(val) === '[object Object]') {
            if($('.selected-current-contents').length > 0){
                this.server.internalRightModalEmit.emit(val);
                $('#internalModalAutoComplate').modal('hide');
            }
        }
    }

}
